﻿namespace Edge.Utilities
{
    using System;
    using System.Net;

    /// <summary>
    /// Contains various networking-related tools.
    /// </summary>
    public static class NetworkingUtilities
    {
        public static string GetLocalIP()
        {
            string hostName = Dns.GetHostName();

            IPHostEntry entry = Dns.GetHostByName(hostName);

            return entry.AddressList[0].ToString();
        }

        /// <summary>
        /// Generates a random port number.
        /// </summary>
        /// <returns>Random port number.</returns>
        public static int GetRandomPortNumber()
        {
            Random random = new Random();
            return random.Next(1, 60000);
        }
    }
}
